import type { DataInterface, PageInterface, DeleteBookInterface, UpdateBookInterface } from '#/api'
import request from '@/utils/request'

/**
 * 请求所有书签
 * @param {PageInterface} params
 * @returns
 */
export const getBooksApi = (params?: PageInterface): Promise<DataInterface> => {
  return request({
    url: '/books',
    params
  })
}

/**
 * 删除书签
 * @param {DeleteBookInterface} data
 * @returns
 */
export const deleteBookApi = (data: DeleteBookInterface): Promise<DataInterface> => {
  return request({
    url: `/books/delete`,
    method: 'delete',
    data
  })
}

/**
 * 修改书签
 * @param {UpdateBookInterface} data
 * @returns
 */
export const updateBookApi = (data: UpdateBookInterface): Promise<DataInterface> => {
  return request({
    url: `/books/update`,
    method: 'patch',
    data
  })
}
